<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2023-10-08 13:36:55
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 库位
 */

namespace App\Models;

use App\Traits\SoftDeletesTrait;

class MpcLocation extends BaseModel
{
    use SoftDeletesTrait;
    public $timestamps = true;
    public $table = "basedata_mpc_location";
    protected $guarded = [];
    public function childrentree()
    {
        return $this->hasMany(get_class($this), 'parent_id', 'id')->with(['children'])->orderBy("sort", 'asc');
    }
    public function children()
    {
        return $this->childrentree();
    }
    public function department()
    {
        return $this->belongsTo(Department::class);
    }

    public function parent()
    {
        return $this->belongsTo(get_class($this));
    }
    //库位所属虚拟库的 外加工厂
    public function outfactory()
    {
        return $this->belongsTo(Company::class);
    }
}
